{template 'common/header'}
<div class='container' style='padding:0 5px 10px;margin:0;width:100%'>
    <ul class="nav nav-tabs">
        <!-- <li {if $opp == 'mailsetup'}class="active"{/if}><a href="{php echo $this->createWebUrl('mailsetup');}">基本设置</a></li> -->
        <li {if $opp == 'adminmail'}class="active"{/if}><a href="{php echo $this->createWebUrl('adminmail');}">分组管理</a></li>
        <!-- <li {if $opp == 'mailacode'}class="active"{/if}><a href="{php echo $this->createWebUrl('mailacode');}">分组二维设置</a></li> -->
    </ul>
</div>
<ul class="nav nav-tabs">
    <li {if $operation == 'display'} class="active" {/if}><a href="{php echo $this->createWebUrl('adminmail',array('op' =>'display'))}">分组列表</a></li>
    <li{if empty($adminmail['id']) && $operation == 'post'} class="active" {/if}><a href="{php echo $this->createWebUrl('adminmail',array('op' =>'post'))}">添加分组</a></li>
    <!-- <li{if empty($adminmail['id']) && $operation == 'detail'} class="active" {/if}><a href="">分组详情</a></li> -->
    {if !empty($adminmail['id']) &&  $operation == 'post'}<li  class="active"><a href="{php echo $this->createWebUrl('adminmail',array('op' =>'post','id'=>$adminmail['id']))}">编辑分组</a></li>
    {/if}
</ul>
{if $operation == 'display'}
<div class="panel panel-success">
    <div class="panel-heading">名片分组 >分组管理</div>
</div>
<div class="main panel panel-default">

    <div class="panel-body table-responsive">

        <table class="table table-hover">

            <thead class="navbar-inner">

                <tr>

                    <th style="width:30px;">ID</th>

                    <th>分组名称</th>					

                    <!-- <th>管理员</th> -->

                    <!-- <th>到期时间</th> -->

                    <th>提交时间</th>

                    <th >操作</th>

                </tr>

            </thead>

            <tbody>

            {loop $list $adminmail}

            <tr>

                <td>{$adminmail['id']}</td>

                <td>{$adminmail['mail_name']}</td>

                <!-- <td>{$adminmail['admin_name']}</td> -->

                <!-- <td>{php echo date('Y-m-d H:i:s',$adminmail['end_time'])}</td> -->
                <td>{php echo date('Y-m-d H:i:s',$adminmail['createtime'])}</td>
                <td style="text-align:left;">
                    <a href="{php echo $this->createWebUrl('adminmail', array('op' => 'detail', 'id' => $adminmail['id']))}" title="详情" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="" data-original-title="详情" ><i class="fa fa-eye"></i>
                    </a>
                    <a href="{php echo $this->createWebUrl('adminmail', array('op' => 'post', 'id' => $adminmail['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>

                    <a href="{php echo $this->createWebUrl('adminmail', array('op' => 'delete', 'id' => $adminmail['id']))}"class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>

                </td>

            </tr>

            {/loop}

            </tbody>

        </table>

        {$pager}

    </div>

</div>

<script>

require(['bootstrap'],function($){

    $('.btn').hover(function(){

        $(this).tooltip('show');

    },function(){

        $(this).tooltip('hide');

    });

});

</script>

{elseif $operation == 'post'}



<div class="main">

    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>

        <input type="hidden" name="id" value="{$adminmail['id']}" />

        <div class="panel panel-default">

            <div class="panel-heading">

                分组设置

            </div>

            <div class="panel-body">



                <div class="form-group">

                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"><span style="color:red">*</span>分组名称</label>

                    <div class="col-sm-9 col-xs-12">

                        <input type="text" id='mail_name' name="mail_name" class="form-control" value="{$adminmail['mail_name']}"/>

                    </div>

                </div>

                <div class="form-group hidden">

                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">管理员名字</label>

                    <div class="col-sm-9 col-xs-12">

                        <input type="text" id='admin_name' name="admin_name" class="form-control" value="{$adminmail['admin_name']}" />

                    </div>

                </div>
                <div class="form-group hidden">

                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red;">管理员OPENID</label>

                    <div class="col-sm-9 col-xs-12">

                        <input type="text" id='admin_openid' name="admin_openid" class="form-control" value="{$adminmail['admin_openid']}" />

                    </div>

                </div>
                <div class="form-group hidden">

                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color:red;">管理员名片ID</label>

                    <div class="col-sm-9 col-xs-12">

                        <input type="text" id='admin_cardid' name="admin_cardid" class="form-control" value="{$adminmail['admin_cardid']}" />

                        <span class="help-block"><font style="color:red;">以上两项红色文字部分非特殊情况不要改动，否则通讯会出问题，（如若改动;管理员OPENID，管理员名片ID必须严格对应）</font></strong></span>

                </div>

            </div>
            <div class="form-group hidden">

                <label class="col-xs-12 col-sm-3 col-md-2 control-label">二维码</label>

                <div class="col-sm-9 col-xs-12">
                    <img src="{php echo tomedia($adminmail['wxacode_b'])}" style="width:150px;"> 
                    <!-- <img src="{php echo tomedia($adminmail['mqrcode'])}" style="width:100px;">--> 
                </div>

            </div>

            <div class="form-group hidden">

                <label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">起止时间</label>

                <div class="col-sm-8 col-lg-9 col-xs-12">

                    {php echo tpl_form_field_daterange('activity',array('start'=>date('Y-m-d H:i:s',empty($adminmail['start_time'])?time():$adminmail['start_time']),'end'=>date('Y-m-d H:i:s',empty($adminmail['end_time'])?time()+3600*5:$adminmail['end_time'])),true);}

                    <span class="help-block"><font style="color:red;">分组起止时间</font></strong></span>

            </div>

        </div>


        <div class="form-group hidden">

            <label class="col-xs-12 col-sm-3 col-md-2 control-label">审核状态</label>

            <div class="col-sm-9 col-xs-12">

                <label class='radio-inline'>

                    <input type='radio' name='mail_key' value=1' {if $adminmail['mail_key']==1}checked{/if} /> 通过

                </label>

                <label class='radio-inline'>

                    <input type='radio' name='mail_key' value=0' {if $adminmail['mail_key']==0}checked{/if} /> 关闭

                </label>

            </div>

        </div>

    </div>

</div>

<div class="form-group col-sm-12">

    <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />

    <input type="hidden" name="token" value="{$_W['token']}" />

</div>

    </form>

</div>




<script language='javascript'>

function formcheck() {

    if ($("#advname").isEmpty()) {

        Tip.focus("advname", "请填写幻灯片名称!");

        return false;

    }

    return true;

}

</script>

{elseif $operation == 'detail'}
<div class="main panel panel-default">

    <div class="panel-body table-responsive">

<table class="table table-hover">

    <thead class="navbar-inner">

        <tr>

            <th style="width:30px;">ID</th>

            <th>姓名</th>					

            <th>职务</th>

            <th>电话</th>

            <th>公司</th>

            <th>地址</th>

            <th >操作</th>

        </tr>

    </thead>

    <tbody>

    {loop $list $adminmail}

    <tr>

        <td>{$adminmail['id']}</td>

        <td>{$adminmail['cardname']}</td>

        <td>{$adminmail['job']}</td>

        <td>{$adminmail['mobile']}</td>

        <td>{$adminmail['company']}</td>

        <td>{$adminmail['address']}</td>

        <td style="text-align:left;">

            <!-- <a href="{php echo $this->createWebUrl('adminmail', array('op' => 'detail', 'id' => $adminmail['id']))}" title="详情" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="" data-original-title="详情" ><i class="fa fa-eye"></i> -->
                            </a>
                        <a href="{php echo $this->createWebUrl('cards', array('op' => 'post', 'id' => $adminmail['id']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>

                        <a href="{php echo $this->createWebUrl('cards', array('op' => 'del', 'id' => $adminmail['id']))}"class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>

                    </td>

        </tr>

        {/loop}

        </tbody>

    </table>

    {$pager}

</div>

</div>

<script>

require(['bootstrap'],function($){

    $('.btn').hover(function(){

        $(this).tooltip('show');

    },function(){

        $(this).tooltip('hide');

    });

});

</script>

{/if}

{template 'common/footer'}
